package com.ruoyi.web.controller.solidProdution;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.solidProdution.domain.CfkInfo;
import com.ruoyi.solidProdution.service.ICfkInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 产废口信息Controller
 * 
 * @author ruoyi
 * @date 2021-09-02
 */
@RestController
@RequestMapping("/solidProdution/cfkInfo")
public class CfkInfoController extends BaseController
{
    @Autowired
    private ICfkInfoService cfkInfoService;

    /**
     * 查询产废口信息列表
     */
    @PreAuthorize("@ss.hasPermi('solidProdution:cfkInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(CfkInfo cfkInfo)
    {
        startPage();
        List<CfkInfo> list = cfkInfoService.selectCfkInfoList(cfkInfo);
        return getDataTable(list);
    }

    /**
     * 导出产废口信息列表
     */
    @PreAuthorize("@ss.hasPermi('solidProdution:cfkInfo:export')")
    @Log(title = "产废口信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CfkInfo cfkInfo)
    {
        List<CfkInfo> list = cfkInfoService.selectCfkInfoList(cfkInfo);
        ExcelUtil<CfkInfo> util = new ExcelUtil<CfkInfo>(CfkInfo.class);
        return util.exportExcel(list, "产废口信息数据");
    }

    /**
     * 获取产废口信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('solidProdution:cfkInfo:query')")
    @GetMapping(value = "/{cfkId}")
    public AjaxResult getInfo(@PathVariable("cfkId") Long cfkId)
    {
        return AjaxResult.success(cfkInfoService.selectCfkInfoById(cfkId));
    }

    /**
     * 新增产废口信息
     */
    @PreAuthorize("@ss.hasPermi('solidProdution:cfkInfo:add')")
    @Log(title = "产废口信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CfkInfo cfkInfo)
    {
        return toAjax(cfkInfoService.insertCfkInfo(cfkInfo));
    }

    /**
     * 修改产废口信息
     */
    @PreAuthorize("@ss.hasPermi('solidProdution:cfkInfo:edit')")
    @Log(title = "产废口信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CfkInfo cfkInfo)
    {
        return toAjax(cfkInfoService.updateCfkInfo(cfkInfo));
    }

    /**
     * 删除产废口信息
     */
    @PreAuthorize("@ss.hasPermi('solidProdution:cfkInfo:remove')")
    @Log(title = "产废口信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cfkIds}")
    public AjaxResult remove(@PathVariable Long[] cfkIds)
    {
        return toAjax(cfkInfoService.deleteCfkInfoByIds(cfkIds));
    }
}
